using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;

namespace Gko.Video.Extensions
{
	[Serializable]
	public class DisplayStandard
	{
		private readonly string name;
		private readonly string fullName;
		private readonly string description;
		private readonly DisplayMode[] modes;

		private static readonly DisplayStandard[] StandardsArray = GetStandards().ToArray();

		private static IEnumerable<DisplayStandard> GetStandards()
		{
			// NOTE: all info at http://en.wikipedia.org/wiki/Computer_display_standard
			// TODO: add other standards
			yield return new DisplayStandard("MDA", "Monochrome Display Adapter", "The original standard on IBM PCs and IBM PC XTs with 4 KB video RAM. Introduced in 1981 by IBM. Supports text mode only", new DisplayMode(new Resolution(720, 350), new ColorDepth(1)));
			yield return new DisplayStandard("CGA", "Color Graphics Adapter", "Introduced in 1981 by IBM, as the first color display standard for the IBM PC. The standard CGA graphics cards were equipped with 16 KB video RAM.", new DisplayMode(new Resolution(640, 200), new ColorDepth(1)), new DisplayMode(new Resolution(320, 200), new ColorDepth(2)), new DisplayMode(new Resolution(160, 200), new ColorDepth(4)));
			yield return new DisplayStandard("Hercules", "", "A monochrome display capable of sharp text and graphics for its time of introduction. Very popular with the Lotus 1-2-3 spreadsheet, which was one of the PC's first killer apps. Introduced in 1982.", new DisplayMode(new Resolution(720, 348), new ColorDepth(1)));
			yield return new DisplayStandard("EGA", "Enhanced Graphics Adapter", "Introduced in 1984 by IBM. A resolution of 640 ? 350 pixels of 16 different colors (4 bits per pixel, or bpp), selectable from a 64-color palette (2 bits per each of red-green-blue).", new DisplayMode(new Resolution(640, 350), new ColorDepth(4)));
			yield return new DisplayStandard("MCGA", "Multicolor Graphics Adapter", "Introduced on selected PS/2 models in 1987, with reduced cost compared to VGA. MCGA had a 320x200 256 color (from a 262,144 color palette) mode, and a 640x480 mode only in monochrome due to 64k video memory, compared to the 256k memory of VGA.", new DisplayMode(new Resolution(320, 200), new ColorDepth(8)), new DisplayMode(new Resolution(640, 480), new ColorDepth(1)));
			yield return new DisplayStandard("8514", "", "Precursor to XGA and released about the same time as VGA in 1987. 8514/A cards displayed interlaced video at 43.5 Hz.", new DisplayMode(new Resolution(1024, 768), new ColorDepth(8)));
			yield return new DisplayStandard("VGA", "Video Graphics Array", "Introduced in 1987 by IBM. VGA is actually a set of different resolutions, but is most commonly used today to refer to 640 ? 480 pixel displays with 16 colors (4 bits per pixel) and a 4:3 aspect ratio. Other display modes are also defined as VGA, such as 320 ? 200 at 256 colors (8 bits per pixel) and a text mode with 720 ? 400 pixels. VGA displays and adapters are generally capable of Mode X graphics, an undocumented mode to allow increased non-standard resolutions.", new DisplayMode(new Resolution(640, 480), new ColorDepth(4)), new DisplayMode(new Resolution(640, 350), new ColorDepth(4)), new DisplayMode(new Resolution(320, 200), new ColorDepth(4)), new DisplayMode(new Resolution(320, 200), new ColorDepth(8)), new DisplayMode(new Resolution(720, 400), new ColorDepth(4)));
			yield return new DisplayStandard("SVGA", "Super VGA", "A video display standard created by VESA for IBM PC compatible personal computers. Introduced in 1989.", new DisplayMode(new Resolution(800, 600), new ColorDepth(4)));
			//			yield return new DisplayStandard("", "", "", new DisplayMode(new Resolution(, ), new ColorDepth()));
		}

		public static IEnumerable<DisplayStandard> Standards
		{
			get
			{
				return StandardsArray.ToArray();
			}
		}

		public DisplayStandard(string name, string fullName, string description, params DisplayMode[] modes)
		{
			this.name = name;
			this.description = description;
			this.fullName = fullName;
			this.modes = modes;
		}

		public string Name
		{
			[DebuggerStepThrough]
			get
			{
				return this.name;
			}
		}

		public string FullName
		{
			[DebuggerStepThrough]
			get
			{
				return this.fullName;
			}
		}

		public string Description
		{
			[DebuggerStepThrough]
			get
			{
				return this.description;
			}
		}

		public DisplayMode[] Modes
		{
			[DebuggerStepThrough]
			get
			{
				return this.modes.ToArray();
			}
		}
	}
}